package com.systop.party05.utils;

import android.os.CountDownTimer;
import android.widget.TextView;


/**
 * @describe： 倒计时按钮工具类
 * @createdate：2017/3/30 16:46
 *
 * 调用：
 * CountDownTimerUtils mCountDownTimerUtils = new CountDownTimerUtils(mButton, 60000, 1000);
 * mCountDownTimerUtils.start();
 */

public class CountDownTimerUtils extends CountDownTimer {

    private TextView mTextView;


    public int getTimerStatu() {
        return timerStatu;
    }

    //0 初始状态   1工作状态   2结束状态
    private  int timerStatu=0;


    public CountDownTimerUtils(TextView textView, long millisInFuture, long countDownInterval) {
        super(millisInFuture, countDownInterval);
        this.mTextView = textView;
    }

    @Override
    public void onTick(long millisUntilFinished) {
        mTextView.setClickable(false); //设置不可点击
        mTextView.setText(millisUntilFinished / 1000 + " s");  //设置倒计时时间
        timerStatu=1;
    }

    @Override
    public void onFinish() {
        mTextView.setText("重新获取");
        mTextView.setClickable(true);//重新获得点击
        timerStatu=2;
    }

}
